# Importing Data
SWEDEN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "AE1:AE229")

# Checking the Imported Data
View(SWEDEN)
# Creating Time Series Data
SWEDEN_ts <- ts(SWEDEN, start=c(1998,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
SWEDEN_ts
sum(is.na(SWEDEN_ts))
library(forecast)
SWEDEN_ts <- tsclean(SWEDEN_ts)
SWEDEN_ts

# Identification: Plotting the Time Series Data
plot(SWEDEN_ts)

# Estimating the appropriate model
SWEDEN_ts_model <- auto.arima(SWEDEN_ts)
SWEDEN_ts_model

# Forecasting
options(max.print=1000000)
SWEDEN_ts_forecast <- forecast (SWEDEN_ts_model, level=c(95), h=288)
plot(SWEDEN_ts_forecast)
SWEDEN_ts_forecast             

# Exporting
write.table(SWEDEN_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/SWEDEN_TSA.csv", sep=",")
